package com.doit.spark.day01

import org.apache.log4j.{Level, Logger}
import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @DATE 2022/1/2/16:46
 * @Author MDK
 * @Version 2021.2.2
 * */
object C01_Demo02 {
  Logger.getLogger("org").setLevel(Level.ERROR)
  def main(args: Array[String]): Unit = {
    val conf = new SparkConf().setAppName("demo").setMaster("local[*]")
    val sc = new SparkContext(conf)
    val rdd1 = sc.textFile("data/word.txt")
    val rdd2: RDD[String] = rdd1.flatMap(_.split("\\s+"))
    val rdd3 = rdd2.map(word => {
      println("map.....")
      (word, 1)
    })
    rdd3.foreach(println)
  }
}
